package hash;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 十八岁讨厌编程
 * @date 2025/6/27 21:15
 * @PROJECT_NAME leetcode
 * @description
 */

public class Solution1 {


    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> records = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int need = target - nums[i];
            if (records.get(need) == null) records.put(nums[i], i);
            else return new int[]{i, records.get(need)};
        }
        return null;
    }


}
